package com.henry.newscafe;

public class NewsCafe {
    public static void main(String[] args) {
        Reader readerJill = new Reader("Jill");
        Reader readerJack = new Reader("Jack");
        Newspaper paperTimes = new Newspaper("The Times");
        Newspaper paperGuardian = new Newspaper("The Guardian");

        // after 'subscribing' a newspaper, a reader should be notified whenever this paper updates an article

        System.out.println("# Jill subscribes The Times.");
        readerJill.subscribe(paperTimes);
        // The Times' subscriber: Jill
        System.out.println("- The Times updates an article.");
        paperTimes.addArticle("Stormy Weather");

        System.out.println("# Jill subscribes The Guardian.");
        readerJill.subscribe(paperGuardian);
        System.out.println("# Jack subscribes The Guardian.");
        readerJack.subscribe(paperGuardian);

        // The Times' subscriber: Jill
        // The Guardian's subscriber: Jill, Jack

        System.out.println("- The Guardian updates an article.");
        paperGuardian.addArticle("A Bad News");

        System.out.println("- The Guardian updates an article.");
        paperGuardian.addArticle("A Good News");

        System.out.println("- The Times updates an article.");
        paperTimes.addArticle("Sunny Weather");
    }
}
